<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('用户等级列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								等级：<input type="text" name="level"/>
							</li>

							

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="levelAdd()" shiro:hasPermission="UserLevel:userLevel:add">
					<i class="fa fa-plus"></i> 添加新等级
				</a>
			
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('UserLevel:userLevel:edit')}]];
        var removeFlag = [[${@permission.hasPermi('UserLevel:userLevel:remove')}]];
        var prefix = ctx + "UserLevel/userLevel";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "用户等级",
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : '主键',
					visible: false
				},
				{
					field : 'level', 
					title : '等级',
					sortable: true
				},
				{
					field : 'levelName', 
					title : '等级名称',
					sortable: true
				},
			
				{
					field : 'updateCondition', 
					title : '升级条件',
					sortable: true
				},
				{
					field : 'state', 
					title : '状态',
					sortable: true
				},			
				{
					field : 'jinbi', 
					title : '等级赠送金币',
					sortable: true
				},
				{
					field : 'bili', 
					title : '优惠比例',
					sortable: true
				},
				{
					field : 'createDate', 
					title : '建立日期',
					sortable: true
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="levelUpdate(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
		            	actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="levelCheck(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
        
        function levelUpdate(id) {
        	$.modal.open('编辑', prefix + "/edit/" + id, '1300', '800');			
		}
        
        function levelAdd() {
        	$.modal.open('添加', prefix + "/add" , '1300', '800');			
		}
        
        function levelCheck(id) {
        	var options = {
   				title: $.table._option.modalName + "详情",
   				width: 1300,
   				height: 800,
   				url: prefix + "/edit/" + id,
   				skin: 'layui-layer-gray', 
   				btn: ['关闭'],
   				yes: function (index, layero) {
   	                layer.close(index);
                }
   			};
        	$.modal.openOptions(options);
        }
    </script>
</body>
</html>